﻿# -*- coding:UTF-8 -*-
#!/usr/bin/env python

import os

def error500(self , reason , path = '500.html' , lang = "html"):
    self.response.clear()
    self.response.set_status(500)
    path = os.path.join(os.path.dirname(__file__), path)
    if lang == "json":
        from django.utils import simplejson as json
        self.response.out.write(json.dumps({"fatal_error":reason}))
    else:
        from google.appengine.ext.webapp import template
        template_values = {
            'reason': reason
        }
        self.response.out.write(template.render(path, template_values))